package com.cy.sc.ribbon;

import com.netflix.loadbalancer.AvailabilityFilteringRule;
import com.netflix.loadbalancer.IRule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <br>@class: MyLBRule
 * <br>@description: 自定义ribbon 规则实现
 * <br>@author: cy
 * <br>@date: 2020-04-02 12:49:43
 * <br>@version: 1.0
 * <br>
 * <br>@since: (版本) 作者 时间 注释
 */
@Configuration
public class MyLBRule {
    //核心实现 IRule接口
    //RoundRobinRule 轮训 默认
    //RandomRule 随机
    //AvailabilityFilteringRule 过滤掉不可用，响应慢的后轮训
    //WeightedResponseTimeRule 权重,响应速度越快的实例选择权重越大
    @Bean
    public IRule customLBRule(){
        return new AvailabilityFilteringRule();
    }
}
